<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="爱心基金">
<style>
    .form-horizontal .controls {
        line-height: 40px;
        height: 40px;
    }

    .form-panel .time-input {
        width: 70px;
    }

    .query-button {
        margin-left: 5px;
    }

    .form-horizontal .money-label {
        width: 60px;
    }

    .money-span5 {
        width: 166px;
    }

    .money-p p {
        margin: 0 0 0 10px;
        padding: 0;
        height: 24px;
        line-height: 24px;
        font-size: 12px
    }

    .money-p div {
        float: left;
    }

    .money-p span {
        color: #6cb5f4;
    }

    .form-horizontal .rate-label {
        width: 120px;
    }

    .form-horizontal .time-label {
        width: 60px;
        line-height: 40px;
        margin-left: 20px;
    }

    .form-horizontal .money-label {
        width: 50px;
        line-height: 40px;
        margin-left: 5px;
    }

    .form-horizontal .money-controls {
        margin-left: 5px;
    }

    .money-span2 {
        width: 56px;
    }
</style>
<form id="searchForm" class="form-panel">
    <ul class="panel-content">
        <li>
            <div class="control-group span5">
                <div class="search-controls  controls">
                    <input type="text" name="offlineName" id="title" placeholder="搜索关键字">
                </div>
            </div>
            <div class="form-actions span2">
                <button type="submit" class="query-button button  button-primary">
                    搜索
                </button>
            </div>
                <label class="time-label  control-label">爱心捐款：</label>

                <div class="money-controls controls">
                    <input type="text" class="time-input input-normal" name="sum" id="amountInput" disabled/>
                </div>


            <label class="money-label control-label">已提现：</label>
            <div class="money-controls controls">
                <input type="text" class="time-input input-normal" name="cash" id="cashInput" disabled/>
            </div>
            <label class="money-label control-label">未提现：</label>

            <div class="money-controls controls">
                <input type="text" class="time-input input-normal" name="unCash" id="unCashInput"
                       disabled/>
            </div>

        </li>
    </ul>
</form>
<div id="grid"></div>
<script>
    /*-------------------------------------------------------- 表格数据渲染start-----------------------------------*/
    var Grid = BUI.Grid,
            Store = BUI.Data.Store,
            columns = [
                {title: '序号', dataIndex: 'offlineID', elCls: 'center', width: '10%'},
                {title: '机构名称', dataIndex: 'organizeName', elCls: 'center', width: '20%'},
                {
                    title: '机构级别', dataIndex: 'organizeRank', elCls: 'center', width: '20%', renderer: function (data) {
                    if (data == "1") {
                        return 'A级';
                    }
                    if (data == "2") {
                        return 'B级';
                    } else {
                        return 'C级';
                    }
                }
                },
                {title: '活动名称', dataIndex: 'offlineName', elCls: 'center', width: '20%'},
                {title: '筹得基金', dataIndex: 'offlineSum', elCls: 'center', width: '20%'}
            ];
    var store = new Store({
                url: '${basepath}/manage/offlineAccount/loadAdminData',
                autoLoad: true, //自动加载数据
                params: { //配置初始请求的参数
                    length: '10',
                    status: $("#phone").val()
                },
                pageSize: 10,	// 配置分页数目
                root: 'list',
                totalProperty: 'total'
            }),

            grid = new Grid.Grid({
                render: '#grid',
                columns: columns,
                loadMask: true, //加载数据时显示屏蔽层
                store: store,
                plugins: [Grid.Plugins.CheckSelection], // 插件形式引入多选表格

                // 底部工具栏
                bbar: {
                    pagingBar: true
                }
            });

    grid.render();


    var form = new BUI.Form.HForm({
        srcNode: '#searchForm'

    });

    form.render();

    form.on('beforesubmit', function (ev) {
        //序列化成对象
        var obj = form.serializeToObject();
        obj.start = 0; //返回第一页
        store.load(obj);
        return false;
    });

    /*-------------------------------------------------------- 表格数据渲染end-----------------------------------*/
    //查询的是爱心捐款input、已提现、未提现的值
    function queryInput() {
        $.ajax({
            type: "GET",
            url: "${basepath}/manage/organize/selectAdminFund",
            dataType: "json",
            success: function (data) {
                var uneCash = 0;
                var cash = 0;
                var sum = 0;
                var inputList = data.data;
                $.each(inputList, function (i, o) {
                    //不要取到null值或者没有空值就执行这个语句
                    if (o.unCash != null && o.unCash != "") {
                        uneCash = uneCash + parseFloat(o.unCash);
                    }
                    if (o.cash != null && o.cash != "") {
                        cash = cash + parseFloat(o.cash);
                    }
                    if (o.sum != null && o.sum != "") {
                        sum = sum + parseFloat(o.sum);
                    }
                });
                $("#unCashInput").val(uneCash);
                $("#cashInput").val(cash);
                $("#amountInput").val(sum);
            }

        })
    }
    queryInput();
</script>

</@page.pageBase>